<?php
//全局变量文件夹路径
$GLOBALS['fileSourcePath'] = "F:\\download\\";
$GLOBALS['fileDistPath']="F:\\moive\\video\\";
$GLOBALS['fileServer']="http://".$_SERVER ['HTTP_HOST'].":90/video/";
//获取文件文件
function getFile() {
	$dir=$GLOBALS["fileSourcePath"];
    $fileArray[]=NULL;
    if (false != ($handle = opendir ( $dir ))) {
        $i=0;
        while ( false !== ($file = readdir ( $handle )) ) {
			//window是用的GB2312的编码
			$file=iconv("gb2312","utf-8",$file);
            //去掉"“.”、“..”以及带“.xxx”后缀的文件
            if ($file != "." && $file != ".."&&strpos($file,".")) {
                $fileArray[$i]=$file;
                $i++;
            }
        }
        //关闭句柄
        closedir ( $handle );
    }
    return $fileArray;
}
//创建guid
function create_guid($namespace = '') {     
    static $guid = '';
    $uid = uniqid("", true);
    $data = $namespace;
    $data .= $_SERVER['REQUEST_TIME'];
    $data .= $_SERVER['HTTP_USER_AGENT'];
    //$data .= $_SERVER['LOCAL_ADDR'];
    //$data .= $_SERVER['LOCAL_PORT'];
    $data .= $_SERVER['REMOTE_ADDR'];
    $data .= $_SERVER['REMOTE_PORT'];
    $hash = strtoupper(hash('ripemd128', $uid . $guid . md5($data)));
    $guid =    
            substr($hash,  0,  8) . 
            substr($hash,  8,  4) .
            substr($hash, 12,  4) .
            substr($hash, 16,  4) .
            substr($hash, 20, 12) ;
    return $guid;
  }
	//移动文件
  function RemoveFile($source,$dist)
  {
	$source=iconv("utf-8","gb2312",$source);
	$dist=iconv("utf-8","gb2312",$dist);
	rename($source,$dist);
  }
?>
